import { IErrorInfo } from '@/types/common'
import { apiPost } from '@/utils'

export interface ILoginParams {
  username: string // 用户名
  password: string // 密码
}

// 获取首页数据
export const login = async (params: {
  username: string
  password: string
}): Promise<{ success: boolean; data?: string | IErrorInfo }> => {
  try {
    const data = await apiPost<string>('/user/login', params)
    return { success: true, data }
  } catch (e) {
    return { success: false, data: e }
  }
}
